home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / srcuc.zip / BIGNUM.H < prev    next >
C/C++ Source or Header  |  1992-02-10  |  4KB  |  99 lines

  1. /* -*-C-*-
  2.  
  3. $Header: /scheme/src/microcode/RCS/bignum.h,v 9.27 1992/02/10 13:16:02 jinx Exp $
  4.  
  5. Copyright (c) 1989-1992 Massachusetts Institute of Technology
  6.  
  7. This material was developed by the Scheme project at the Massachusetts
  8. Institute of Technology, Department of Electrical Engineering and
  9. Computer Science.  Permission to copy this software, to redistribute
  10. it, and to use it for any purpose is granted, subject to the following
  11. restrictions and understandings.
  12.  
  13. 1. Any copy made of this software must include this copyright notice
  14. in full.
  15.  
  16. 2. Users of this software agree to make their best efforts (a) to
  17. return to the MIT Scheme project any improvements or extensions that
  18. they make, so that these may be included in future releases; and (b)
  19. to inform MIT of noteworthy uses of this software.
  20.  
  21. 3. All materials developed as a consequence of the use of this
  22. software shall duly acknowledge such use, in accordance with the usual
  23. standards of acknowledging credit in academic research.
  24.  
  25. 4. MIT has made no warrantee or representation that the operation of
  26. this software will be error-free, and MIT is under no obligation to
  27. provide any services, by way of maintenance, update, or otherwise.
  28.  
  29. 5. In conjunction with products arising from the use of this material,
  30. there shall be no use of the name of the Massachusetts Institute of
  31. Technology nor of any adaptation thereof in any advertising,
  32. promotional, or sales literature without prior written consent from
  33. MIT in each case. */
  34.  
  35. /* External Interface to Bignum Code */
  36.  
  37. /* The `unsigned long' type is used for the conversion procedures
  38.    `bignum_to_long' and `long_to_bignum'.  Older implementations of C
  39.    don't support this type; if you have such an implementation you can
  40.    disable these procedures using the following flag (alternatively
  41.    you could write alternate versions that don't require this type). */
  42. /* #define BIGNUM_NO_ULONG */
  43.  
  44. #include "ansidecl.h"
  45.  
  46. #ifdef MIT_SCHEME
  47.  
  48. typedef SCHEME_OBJECT bignum_type;
  49. #define BIGNUM_OUT_OF_BAND SHARP_F
  50.  
  51. #else
  52.  
  53. typedef long * bignum_type;
  54. #define BIGNUM_OUT_OF_BAND ((bignum_type) 0)
  55.  
  56. #endif
  57.  
  58. enum bignum_comparison
  59. {
  60.   bignum_comparison_equal, bignum_comparison_less, bignum_comparison_greater
  61. };
  62.  
  63. typedef PTR bignum_procedure_context;
  64. extern bignum_type EXFUN (bignum_make_zero, (void));
  65. extern bignum_type EXFUN (bignum_make_one, (int negative_p));
  66. extern int EXFUN (bignum_equal_p, (bignum_type, bignum_type));
  67. extern enum bignum_comparison EXFUN (bignum_test, (bignum_type));
  68. extern enum bignum_comparison EXFUN (bignum_compare,
  69.                      (bignum_type, bignum_type));
  70. extern bignum_type EXFUN (bignum_add, (bignum_type, bignum_type));
  71. extern bignum_type EXFUN (bignum_subtract, (bignum_type, bignum_type));
  72. extern bignum_type EXFUN (bignum_negate, (bignum_type));
  73. extern bignum_type EXFUN (bignum_multiply, (bignum_type, bignum_type));
  74. extern int EXFUN (bignum_divide,
  75.           (bignum_type numerator, bignum_type denominator,
  76.            bignum_type * quotient, bignum_type * remainder));
  77. extern bignum_type EXFUN (bignum_quotient, (bignum_type, bignum_type));
  78. extern bignum_type EXFUN (bignum_remainder, (bignum_type, bignum_type));
  79. #ifndef BIGNUM_NO_ULONG
  80. extern bignum_type EXFUN (long_to_bignum, (long));
  81. extern long EXFUN (bignum_to_long, (bignum_type));
  82. #endif /* not BIGNUM_NO_ULONG */
  83. extern bignum_type EXFUN (double_to_bignum, (double));
  84. extern double EXFUN (bignum_to_double, (bignum_type));
  85. extern int EXFUN (bignum_fits_in_word_p,
  86.           (bignum_type, long word_length, int twos_complement_p));
  87. extern bignum_type EXFUN (bignum_length_in_bits, (bignum_type));
  88. extern bignum_type EXFUN (bignum_length_upper_limit, (void));
  89. extern bignum_type EXFUN (digit_stream_to_bignum,
  90.               (unsigned int n_digits,
  91.                unsigned int EXFUN ((*producer), ()),
  92.                bignum_procedure_context context,
  93.                unsigned int radix, int negative_p));
  94. extern void EXFUN (bignum_to_digit_stream,
  95.            (bignum_type, unsigned int radix,
  96.             void EXFUN((*consumer), ()),
  97.             bignum_procedure_context context));
  98. extern long EXFUN (bignum_max_digit_stream_radix, (void));
  99.